//
//  LLVisitorTableViewController.swift
//  xinlangweibo
//
//  Created by 任玉林 on 16/6/25.
//  Copyright © 2016年 任玉林. All rights reserved.
//

import UIKit

class LLVisitorTableViewController: UITableViewController {
    
    
    let isLogin: Bool = LLUserAccountTools.sharedTools.isLogin
    
    // 定义访客视图  延迟加载访客视图用 ？
    var visitorView: LLVisitorView?
    
    override func loadView() {
        
        //判断是否登录
        if isLogin{
            
            super.loadView()
        }else{
            
            setupVisitorView()
        }
    }
    
    //设置访客视图
    private func setupVisitorView(){
        
        setupNav()
        
        //初始化
        visitorView = LLVisitorView()
        
        visitorView?.closue = {
            
            self.loginClick()
        }
        
        view = visitorView
        
        
    }
    
    
    
    
    
 //设置导航控制器
    private func setupNav (){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginClick")
        
        
    }
    
    @objc private func loginClick(){
        
        //点击弹出登录控制器
        let oauthVC = LLOauthViewController()
        
        let naVC = UINavigationController(rootViewController: oauthVC)

        presentViewController(naVC, animated: true
            , completion: nil)
    }
    
    
    override func viewDidLoad(){
        
        super.viewDidLoad()
    }

}
